import {
	hasPermission
} from "@/utils/page.js"
import {
	Switch
} from "@/api/index.js"
export default {
	onLoad() {
		if (!this.share) {
			uni.hideShareMenu();
		}
		if (!this.isNoMixin) {
			Switch().then(res => {
				uni.setStorageSync('status', res.data);
				this.$status = res.data;
				if (!res.data) {
					this.getList && this.getList();
				}
				//真 隐藏内容 假 显示内容
				console.log(this.$status, "登陆的判断");
			})
		}
		var pages = getCurrentPages();
		var page = pages[pages.length - 1];
		var path = this.share.path ? this.share.path : page.$page.fullPath;
		if (!hasPermission(path, true)) {
			//验证是否登陆
			return false
		}
	},
	data() {
		return {
			//设置默认的分享参数
			//如果页面不设置share，就触发这个默认的分享
			share: {
				title: '武信校园墙',
				path: '',
				imageUrl: '',
				desc: '',
				content: ''
			},
			$status: true,
			isNoMixin: false
		}
	},
	onShareTimeline(res) {
		return this.share
	},
	onShow() {

	},
	onShareAppMessage(res) {
		return {
			...this.share,
			success(res) {
				uni.showToast({
					title: '分享成功'
				})
			},
			fail(res) {
				uni.showToast({
					title: '分享失败',
					icon: 'none'
				})
			}
		}
	}
}
